package com.ay272.ssh2.quartz;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.impl.JobDetailImpl;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.triggers.CronTriggerImpl;
import org.quartz.impl.triggers.SimpleTriggerImpl;


import java.io.IOException;
import java.text.ParseException;
import java.util.Date;

/**
 * Created by java on 2016/5/19.
 */
//执行签到测试类
public class text {
    public static void main(String[] args) throws SchedulerException, IOException, ParseException {
      //定义任务详情
        JobDetailImpl jd = new JobDetailImpl();
        jd.setName("myjob");
        jd.setJobClass(MyQianJob.class);
        //触发器
/*        SimpleTriggerImpl st = new SimpleTriggerImpl();
        st.setName("mytr");
        st.setRepeatCount(-1);//无限制执行
        st.setRepeatInterval(10000);
        st.setStartTime(new Date(System.currentTimeMillis()+10000));*/
        //时间函数
        CronTriggerImpl ct = new CronTriggerImpl();
        ct.setName("myct");
        //ct.setCronExpression("0 0 8 ? * 2");//每个月的星期一八点整执行
        //ct.setCronExpression("10 20 30 * * * * ?");//任意时间每遇到10，20，30秒的时候执行
        ct.setCronExpression("* * * 30 4 ?");//每年的4月30号执行
        ct.setStartTime(new Date());
        //调度器
        SchedulerFactory sf = new StdSchedulerFactory();
        Scheduler s = sf.getScheduler();
        s.scheduleJob(jd,ct);
        s.start();
        System.in.read();
        s.shutdown();
    }
}
